home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
UTILITIE
/
UNIX_COH
/
2772.ZIP
/
DUMPSCRE.TAZ
/
DUMPSCRE.tar
Wrap
Text File
|
1991-07-02
|
1KB
|
58 lines
/*
* dumpscreen: take a snapshot of the screen and copy it to stdout.
* note: does not preserve screen attributes.
* usage: dumpscreen [-c]
* use the -c option if using a color video card.
*/
#include <stdio.h>
#define USAGE "usage: dumpscreen [-c]\n\tUse the -c option with a color card."
#define CHARS_PER_LINE 80
#define LINES 25
#define MEM "/dev/mem"
#define MONO_OFFSET 0xB0000L /* start of monochrome screen memory */
#define COLOR_OFFSET 0xB8000L /* start of color screen memory */
long offset = MONO_OFFSET; /* default to mono display adaptor */
char screen[CHARS_PER_LINE * LINES * 2];
main(argc, argv)
int argc;
char *argv[];
{
register char *cp;
register int row, col;
FILE *fp;
if (argc == 2) {
if (argv[1][0] != '-' || argv[1][1] != 'c')
usage();
else
offset = COLOR_OFFSET;
} else if (argc != 1)
usage();
if ((fp = fopen(MEM, "rb")) == NULL)
fatal("unable to access %s", MEM);
fseek(fp, offset, 0);
if (fread(screen, sizeof screen, 1, fp) != 1)
fatal("unable to read screen memory");
for (cp = screen, row = 0; row < LINES; ++row) {
for (col = 0; col < CHARS_PER_LINE; ++col, cp += 2)
putchar(*cp);
putchar('\n');
}
exit(0);
}
usage()
{
fatal(USAGE);
}
fatal(arg)
char *arg;
{
fprintf(stderr, "dumpscreen: %r\n", &arg);
exit(1);
}